package com.www.applyword.ui.home;

import android.widget.TextView;

import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.www.applyword.Constants.Constants;
import com.www.applyword.R;
import com.www.applyword.adapter.JobWorkAdapter2;
import com.www.applyword.base.BaseActivity;
import com.www.applyword.bean.GetIntegerRecordListBean;
import com.www.applyword.http.CallBack;
import com.www.applyword.http.HttpClient;
import com.www.applyword.utils.SPUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;

/**
 * author : huang
 * date   : 2019/11/19 0019 17:01
 * version: 1.0
 */
public class MyFenActivity extends BaseActivity {
    @BindView(R.id.tv)
    TextView tv;

    @BindView(R.id.rl)
    RecyclerView rl;
    private JobWorkAdapter2 jobWorkAdapter2;
    private List<GetIntegerRecordListBean> listBeans = new ArrayList<>();

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.fan_activity);
        setTitle("我的积分");
        tv.setText(SPUtil.getInt(Constants.JIFFEN, 0) + "");

    }

    @Override
    protected void loadData() {
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        rl.setItemAnimator(new DefaultItemAnimator());
        rl.setLayoutManager(layoutManager);
        jobWorkAdapter2 = new JobWorkAdapter2(MyFenActivity.this);
        rl.setAdapter(jobWorkAdapter2);


        Map<String, Object> params = new HashMap<>();
        params.put("UserID", SPUtil.getString(Constants.USERID));
        params.put("Page", "1");
        params.put("Rows", "50");
        HttpClient.get(MyFenActivity.this, Constants.GETINTEGERRECORDLIST, params,new CallBack<List<GetIntegerRecordListBean>>() {
            @Override
            public void onSuccess(List<GetIntegerRecordListBean> result) {
                if (result.size() > 0){
                    listBeans.clear();
                    listBeans.add(result.get(0));
                    listBeans.add(result.get(1));
                    jobWorkAdapter2.replaceAll(listBeans, true);
                }else {
                    showEmpty(true,vsEmpty,0);
                }
            }
        });
    }
}
